Skip to content

Conversation

@Grufoony
Copy link
Collaborator

New features:

  • now algorithms consider exit queues instead of street density
  • queues are weighted basing on the number of lanes
  • bugfixes

@Grufoony Grufoony requested a review from sbaldu January 14, 2025 08:22
@Grufoony Grufoony self-assigned this Jan 14, 2025
densities.reserve(m_graph.streetSet().size());
for (const auto& [streetId, street] : m_graph.streetSet()) {
densities.push_back(street->density(normalized));
if (normalized) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
densities.push_back(street->density(false) * street->length());
sum += street->length();
}
if (sum == 0) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
return Measurement(0., 0.);
}
auto meanDensity{std::accumulate(densities.begin(), densities.end(), 0.) / sum};
return Measurement(meanDensity, 0.);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
std::unordered_map<Id, std::array<unsigned long long, 4>> m_turnCounts;
std::unordered_map<Id, std::array<long, 4>> m_turnMapping;
std::unordered_map<Id, Size> m_streetTails;
std::unordered_map<Id, double> m_streetTails;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
tl.resetCycles();
}
auto const outputDifference{(outputGreenSum - outputRedSum) / nCycles};
if ((inputDifference * outputDifference > 0) ||

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
}
auto const outputDifference{(outputGreenSum - outputRedSum) / nCycles};
if ((inputDifference * outputDifference > 0) ||
std::max(std::abs(inputDifference), std::abs(outputDifference)) < threshold ||

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
double TrafficLight::meanGreenTime(bool priorityStreets) const {
double meanTime{0.};
size_t nCycles{0};
for (auto const& [streetId, cycles] : m_cycles) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
}
}
}
return meanTime / nCycles;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
meanTime += std::accumulate(cycles.begin(),
cycles.end(),
0.,
[](double acc, TrafficLightCycle const& cycle) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
cycles.end(),
0.,
[](double acc, TrafficLightCycle const& cycle) {
return acc + cycle.greenTime();

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
cycles.end(),
0.,
[](double acc, TrafficLightCycle const& cycle) {
return acc + cycle.greenTime();

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
@Grufoony
Copy link
Collaborator Author

I give up about mac

@Grufoony Grufoony merged commit 335af08 into main Jan 15, 2025
15 of 16 checks passed
@Grufoony Grufoony deleted the optAlgo3 branch January 15, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants